export interface ContextConfig {
    frame: number;
}

export abstract class Context {
    /** 累计帧 */
    public frame = 0;
    /** 创建时间 */
    public createTime: Date = new Date();
    /** 更新时间 */
    public updateTime: Date = new Date();

    constructor(config: ContextConfig) {
        this.frame = config.frame ?? 0;
    }

    update(config: ContextConfig): void {
        this.frame = config.frame;
        this.updateTime = new Date();
    }

    getData() {
        return {
            updateTime: this.updateTime,
            createTime: this.createTime,
            frame: this.frame
        };
    }

    reset(): void {
        this.frame = 0;
    }
}
